<template>
  <DynamicForm v-model="formData" :schema="formSchema" @submit="handleSubmit">
    <!-- 自定义插槽 -->
    <template #extraField="{ model, field }">
      <el-input v-model="model[field]" placeholder="这里是自定义插槽输入框" />
    </template>
  </DynamicForm>
</template>

<script setup lang="ts">
import { ref } from "vue";
import DynamicForm from "../components/FormItem.vue";
import { formSchema } from "../config/formData";

const formData = ref({
  username: "张三",
  gender: "male",
  hobbies: ["football"],
  birthday: "2000-01-01",
  avatar: [],
  description: "只读内容",
  customSlot: "123",
});

const handleSubmit = (values: any) => {
  console.log("表单提交数据：", values);
};
</script>
